<?php
require_once(__PHY_LIB.'/class/Item.class.php');

class FnWork extends Item {
	/// definition and constructor ///
	function FnWork($id=0, $field="") {
		Query::Query();
		$this->cfgKeyField("id");
		$this->cfgAllField("id,order_id,work_id,title,quantity,total_price,shop_id,shop_title,shop_price,body_id,body_title,body_sn,body_price,color_id,color_sn,color_cmyk,color_title,size_id,size_title");
		$this->cfgTable("fnnc_unit_work");
		if ("" == $field || "*" == $field) {
			$this->cfgField($this->mAllField);
		}
		else {
			$this->cfgField($field);
		}
		if (0 < $id) {
			$this->cfgWhere($this->mKeyField . "=" . $id);
			$this->load();
		}
		else {
			$this->set($this->mKeyField, $id);
		}
	}

	function loadByOrderClothes($nOrderID, $nWorkID) {
		$this->cfgWhere("order_id='{$nOrderID}' AND work_id='{$nWorkID}'");
		$this->load();
		return (0 < $this->getID());
	}

	function invalid() {
		return false;
	}

} /// end class FnWork.

class FnWorkList extends ItemList {
	/// definition and constructor ///
	function FnWorkList($tablename=null) {
		ItemList::ItemList();
		$this->cfgClass("FnWork");
		$this->cfgKeyField("id");
		$this->cfgAllField("id,order_id,work_id,title,quantity,total_price,shop_id,shop_title,shop_price,body_id,body_title,body_sn,body_price,color_id,color_sn,color_cmyk,color_title,size_id,size_title");
		$this->cfgTable(null == $tablename ? "fnnc_clothes" : $tablename);
	}

} /// end class FnWorkList.
?>
